package com.ai.demo.service;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.openai.OpenAiChatModel;
import org.springframework.ai.openai.OpenAiChatOptions;
import org.springframework.ai.openai.api.OpenAiApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 提示词模板
 */
@Service
public class PromptTemplatesService {
    @Autowired
    private OpenAiChatModel baseChatModel;

    @Autowired
    private OpenAiApi baseOpenAiApi;

    public String getMoviesByComposer(String composer) {
        OpenAiChatModel openAiChatModel = baseChatModel.mutate()
                .openAiApi(baseOpenAiApi)
                .defaultOptions(OpenAiChatOptions.builder().model("deepseek-chat").temperature(0.7).build())
                .build();

        return ChatClient.create(openAiChatModel).prompt()
                .user(u -> u
                        .text("请告诉我由{composer}作曲配乐的5部电影名称")
                        .param("composer", composer))
                .call()
                .content();
    }

}
